package com.jinxin.platform.cdacsrecord.core.task;

import com.jinxin.platform.cdacsrecord.core.mapper.JurenAcsControlRecordInfoMapper;
import com.jinxin.platform.cdacsrecord.core.pojo.domains.AcsControlRecordInfo;
import com.jinxin.platform.cdacsrecord.core.service.AcsControlAsyncService;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Description: apcos-acs
 * Created by 34759 on 2020/4/28 13:58
 */
@EnableScheduling
@Component
@Configuration
public class AcsScheduledTask {

    @Autowired
    public SchedulerAllJob myScheduler;

    @Bean
    public SchedulerFactoryBean schedulerFactoryBean() {
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        return schedulerFactoryBean;
    }
    // 开机启动
    @Bean(destroyMethod = "shutdown")
    public void taskSchedulerJob() {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        executorService.execute(() -> {
            try {
                myScheduler.scheduleDayJobs();
            } catch (SchedulerException e) {
                e.printStackTrace();
            }
        });
    }
}
